#ifndef SLAVESLOT_H
#define SLAVESLOT_H

#include <QWidget>
#include <QMutexLocker>
#include "qneedleindicator.h"
#include "qledindicator.h"
#include <QVBoxLayout>
#include <QTimer>
#include <QLabel>


#define  kMaxElementInQueue     1000


namespace Ui {
    class SlaveSlot;
}

class SlaveSlot : public QWidget {
    Q_OBJECT
public:
    SlaveSlot(QWidget *parent = 0);
    ~SlaveSlot();
    //
    // public interface to use:
    bool                isConnected(void) {return m_isConnected;}
    void                setConnected(bool status);
    void                setActiveStatus(bool activity);
    const QString       getInfoSocket(void) {return this->m_InfoSocket->text();}
    void                setInfoSocket(QString& info);    
    void                addInQueueLabel(int val);    
    void                resetSlot(void);
    void                acquireLock(void);
    void                releaseLock(void);
    //
    // use internal only:
    qint64             unitInQueue; // unit in slave queue
    qint64             unitWorked; // unit processed

public slots:    
    void                updateQueueIndicator();
    void                addWorkedFromQueueLabel();

protected:
    void                changeEvent(QEvent *e);
    void                timerEvent(QTimerEvent *);

private:
    Ui::SlaveSlot       *ui;
    QMutex              m_mutex;
    QNeedleIndicator    *m_indicator;
    QLedIndicator       *m_ledStatus;
    QLedIndicator       *m_ledConnectionStatus;    
    QLabel              *m_InfoSocket; // information about socket connection
    QLabel              *m_unitInQueue;
    QLabel              *m_unitWorkedFromQueue;
    bool                m_isConnected; // activates led status if slave is connected with master
    char                currentBlinkingLed; // for alternate blink on m_ActivityStatus
    int                 timerID;
};

#endif // SLAVESLOT_H
